package com.txts.road.app.map.controller;

import com.txts.road.app.map.model.dto.NavigationStartDTO;
import com.txts.road.app.map.model.dto.RoutePlanDTO;
import com.txts.road.app.map.model.query.POIQuery;
import com.txts.road.app.map.model.query.PlaceSearchQuery;
import com.txts.road.app.map.model.vo.FavoritePlaceVO;
import com.txts.road.app.map.model.vo.LocationPointVO;
import com.txts.road.app.map.model.vo.WeatherVO;
import com.txts.road.app.map.service.LocationPointService;
import com.txts.base.common.domain.ResponseDTO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;


/**
 * 位置点前端控制层
 *
 * @author baoyr
 * @since 2025-07-17 10:42
 */
@Tag(name = "位置点接口")
@RestController
@RequestMapping("/api/v1/location-point")
@RequiredArgsConstructor
public class LocationPointController {

    private final LocationPointService locationPointService;

    /**
     * 搜索地点
     */
    @Operation(summary = "搜索地点")
    @PostMapping("/search")
    public ResponseDTO<List<FavoritePlaceVO>> searchPlace(@RequestBody PlaceSearchQuery searchDTO) {
        return ResponseDTO.ok(locationPointService.searchPlace(searchDTO));
    }

    /**
     * 路径规划
     */
    @Operation(summary = "路径规划")
    @PostMapping("/route/plan")
    public ResponseDTO<Boolean> planRoute(@Valid @RequestBody RoutePlanDTO planDTO) {
        return ResponseDTO.ok(locationPointService.planRoute(planDTO));
    }

    /**
     * 导航
     */
    @Operation(summary = "开始导航")
    @PostMapping("/navigation/start")
    public ResponseDTO<Boolean> startNavigation(@Valid @RequestBody NavigationStartDTO startDTO) {
        return ResponseDTO.ok(locationPointService.startNavigation(startDTO));
    }

    /**
     * 获取天气信息
     */
    @Operation(summary = "获取天气信息")
    @GetMapping("/weather")
    public ResponseDTO<WeatherVO> getWeather(@RequestParam Double latitude, @RequestParam Double longitude) {
        return ResponseDTO.ok(locationPointService.getWeather(latitude, longitude));

    }

    /**
     * 获取兴趣点
     */
    @Operation(summary = "获取兴趣点")
    @PostMapping("/poi")
    public ResponseDTO<LocationPointVO> getPOI(@Valid @RequestBody POIQuery query) {
        return ResponseDTO.ok(locationPointService.getPOI(query));
    }

}
